SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from "react";
  2. import { Rect } from "react-konva";
  3. import { CLASS_IDS } from "../../lib/environmentApi";
  4. class EntityRect extends React.Component {
  5.   handleClick = () => {
  6.     this.setState({
  7.       clicked: true
  8.     });
  9.   };
  10.  
  11.   render() {
  12.     const {
  13.       entity,
  14.       screenPos,
  15.       worldPos,
  16.       width,
  17.       height,
  18.       selected,
  19.       onClick
  20.     } = this.props;
  21.     let fill = "white";
  22.     if (!entity || entity.classID === CLASS_IDS.EMPTY) { // Empty
  23.       fill = "#32ff7e";
  24.     } else if (entity.classID === CLASS_IDS.AGENT) { // Agent
  25.       fill = "#18dcff";
  26.     } else if (entity.classID === CLASS_IDS.ROCK) { // Rock
  27.       fill = "#000000";
  28.     } else if (entity.classID === CLASS_IDS.FOOD) { // Food
  29.       fill = "#33c466";
  30.     }
  31.     return (
  32.       <Rect
  33.         x={screenPos.x}
  34.         y={screenPos.y}
  35.         width={width}
  36.         height={height}
  37.         fill={fill}
  38.         shadowBlur={selected ? 5 : 0}
  39.         onClick={() => onClick(worldPos, entity)}
  40.       />
  41.     );
  42.   }
  43. }
  44.  
  45. export default EntityRect;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top