"""The fort, cut away (Step 3f; Dillon's design, 2026-11-16). Panda3D. The base seen from the side with its front wall gone, every room on view at once: the command room and the garage bay on the top level (the garage's ramp runs up to the surface), the barracks, rec area, armory and engineer bay below, then research and the plots, and a lift shaft down the middle (rooms.LAYOUT). Click a room, or its tab along the bottom of the screen, and the view glides to it: back a little, across, and in. The Base tab pulls back out to the whole cutaway. Going to the command room glides in, then you're at the war room's map table (warroom.py) as before. Each room has its furniture and someone at work, and holds the controls that exist today, in the same windows as the 2D game (campaignview.BunkerDesks): the roster (barracks, armory), the convoy (garage), building (engineer bay, and any plot). Research and the rec area have nothing to work yet. Moving about costs no game days; a trip on the road plays on while you're away from the table. python -m p02.warroom the base and the war room, for the saved campaign """ from __future__ import annotations import math import tkinter as tk from panda3d.core import (AmbientLight, BitMask32, CollisionHandlerQueue, CollisionNode, CollisionRay, CollisionTraverser, DirectionalLight, PointLight, TextNode, Vec4) from . import rooms as R from . import shapes as S from .warroom import CONCRETE, DRAB, PICK, STEEL, WOOD, ease, figure, lerp CELL_W, CELL_H = 7.0, 3.6 # one column of the cutaway, one level: wall to wall, floor to floor DEPTH = 6.0 # front (the cut, y = 0) to the back wall WALL = 0.4 # the concrete between rooms, and under each level SHELL = 0.6 # the base's outer concrete SURFACE = 1.4 # earth over the top level, to the ground DADO = 1.2 # walls painted olive to this height, grey above GLIDE_SECONDS = 1.3 # room to room PULL = 0.4 # how far the view backs off mid-glide, for each metre it goes EARTH, ROCK, GRASS = "#4a3b2c", "#5b4f42", "#556b35" WALLS, SLABS = "#77756e", "#64625c" # poured concrete OLIVE, PAINT, SANDBAG = "#56603f", "#a3a197", "#a08e62" # the paint inside; sandbags BASE_HINT = "The fort. Click a room, or a tab below, to go to it." STAFF = {"command": (2.6, 1.0, 200, DRAB), "barracks": (0.6, 1.0, 180, DRAB), "armory": (0, 1.4, 180, "#5a5f3c"), "engineering": (-1.2, 2.2, 180, "#5a5f3c"), "garage": (-1.8, 0.6, 200, "#4a4a40"), "research": (1.0, 1.6, 0, "#d8d8d0"), "rec": (0.4, 1.2, 0, DRAB), "machine shop": (0.8, 1.9, 0, "#4a4a40"), "infirmary": (1.4, 0.2, 200, "#d8d8d0"), "drill yard": (-1.4, 0.6, 0, DRAB), "radio room": (0.6, 2.0, 0, DRAB), "building": (0.4, 0.6, 160, "#6b5a3c")} # ── where things are (pure: no Panda) ── def cell(key): """A room's box in the cutaway -> (x0, x1, z0, z1): its inside, wall to wall, floor to ceiling.""" level, col, span = R.LAYOUT[key] x0 = (col - R.COLUMNS / 2) * CELL_W + WALL / 2 x1 = (col + span - R.COLUMNS / 2) * CELL_W - WALL / 2 z0 = -(level + 1) * CELL_H return x0, x1, z0, z0 + CELL_H - WALL def room_pose(key): """The view into one room: from just in front of the cut, the whole room framed.""" x0, x1, z0, _ = cell(key) w = x1 - x0 back = (w / 2 + 0.3) / math.tan(math.radians(30)) # the lens is 60 degrees across return ((x0 + x1) / 2, -back + 1.2, z0 + 1.5 + w * 0.05), (0.0, -6.0, 0.0) def base_pose(): """The whole cutaway, from the mast and the tower down to the lift pit, and out to the ramp's gate (set off to the right for it). The news covers the top left, the tabs the bottom: framed between.""" return (3.5, -44.0, -6.0), (0.0, 0.0, 0.0) def glide(a, b, k): """The view k (0..1) of the way from pose a to pose b: across and in, backing off on the way.""" e = ease(k) pos, hpr = list(lerp(a[0], b[0], e)), lerp(a[1], b[1], e) pos[1] -= min(12.0, PULL * math.dist(a[0], b[0])) * math.sin(math.pi * e) return tuple(pos), hpr def room_xy(x, y): """Furniture laid out for a 7 by 7 room (door at y -3.5) -> its place in a cutaway cell.""" return x, DEPTH / 2 + y * (DEPTH - 0.4) / 7.4 # ── the rooms' furniture: (name, size x y z, colour, at x y z), laid out for a 7 by 7 room ── def bunk(x, y): return [("bunk", (0.9, 2.0, 0.45), "#5d5f4a", (x, y, 0)), ("blanket", (0.85, 1.6, 0.08), "#6b6f45", (x, y + 0.15, 0.45)), ("pillow", (0.6, 0.3, 0.1), "#d8d2bf", (x, y - 0.8, 0.45))] FURNITURE = { "command": [("map table", (3.0, 2.0, 0.9), WOOD, (-1.0, 0.8, 0)), ("map", (2.8, 1.8, 0.02), "#d8c79c", (-1.0, 0.8, 0.9)), ("radio desk", (1.6, 0.8, 0.8), WOOD, (3.2, 2.6, 0)), ("radio set", (1.0, 0.5, 0.6), "#3d4a3a", (3.2, 2.7, 0.8)), ("board", (3.4, 0.08, 0.9), "#7a5c3a", (-1.0, 3.3, 0.95))] + [("cabinet", (0.8, 0.6, 1.5), "#596356", (x, 3.0, 0)) for x in (-5.6, -4.7)], "barracks": bunk(-2.6, 1.8) + bunk(-2.6, -0.8) + bunk(2.6, 1.8) + bunk(2.6, -0.8) + [("locker", (0.6, 0.5, 1.8), "#5b6656", (x, 3.2, 0)) for x in (-1.2, -0.4, 0.4, 1.2)], "armory": [("rack", (4.0, 0.4, 1.9), WOOD, (0, 3.1, 0))] + [("rifle", (0.07, 0.07, 1.1), "#2a2a28", (-1.7 + i * 0.37, 2.85, 0.6)) for i in range(10)] + [("counter", (3.0, 0.8, 1.0), WOOD, (0, 0.6, 0))] + [("ammo crate", (0.7, 0.45, 0.4), "#5e6b3a", (-2.8, -1.5 + i * 0.6, 0)) for i in range(3)], "garage": [("truck bed", (1.7, 2.4, 0.8), "#4d5a33", (1.2, 2.2, 0.5)), ("cab", (1.7, 1.1, 1.1), "#4d5a33", (1.2, 0.4, 0.5)), ("windscreen", (1.4, 0.05, 0.45), "#9fb3b8", (1.2, -0.16, 1.05))] + [("wheel", (0.25, 0.8, 0.8), "#222222", (1.2 + sx * 0.9, wy, 0)) for sx in (-1, 1) for wy in (0.4, 2.6)] + [("cart", (1.2, 1.8, 0.5), WOOD, (-3.4, 1.6, 0.4)), ("hay", (1.0, 1.0, 0.6), "#c9b25e", (-5.0, 0.6, 0)), ("fuel drum", (0.5, 0.5, 0.9), "#7a3324", (3.6, 2.8, 0)), ("fuel drum", (0.5, 0.5, 0.9), "#7a3324", (4.2, 2.8, 0))], "engineering": [("desk", (2.0, 1.0, 0.8), WOOD, (-1.2, 1.4, 0)), ("plans", (1.6, 0.8, 0.02), "#cfd9e6", (-1.2, 1.4, 0.8)), ("drafting board", (1.2, 0.1, 0.9), "#d8c79c", (1.8, 2.6, 1.0)), ("cabinet", (0.9, 0.6, 1.5), "#596356", (2.8, 0.2, 0)), ("cabinet", (0.9, 0.6, 1.5), "#596356", (2.8, -0.6, 0))], "research": [("bench", (3.0, 0.9, 0.9), "#d9d6cc", (-0.6, 2.8, 0)), ("bench", (0.9, 2.2, 0.9), "#d9d6cc", (-2.7, 0.8, 0))] + [("jar", (0.18, 0.18, 0.3), c, (-1.6 + i * 0.5, 2.8, 0.9)) for i, c in enumerate(("#7fa38a", "#c9b25e", "#9fb3b8", "#a8584a", "#7fa38a"))] + [("chalkboard", (2.4, 0.06, 1.2), "#2f3a2e", (1.8, 3.3, 1.0)), ("stool", (0.4, 0.4, 0.6), WOOD, (0.4, 1.8, 0))], "rec": [("couch", (0.8, 2.2, 0.5), "#6b4a3a", (-2.9, -0.6, 0)), ("couch back", (0.25, 2.2, 0.5), "#6b4a3a", (-3.25, -0.6, 0.5)), ("card table", (1.2, 1.2, 0.75), WOOD, (1.6, -0.8, 0)), ("crate", (0.6, 0.6, 0.45), "#7a5c3a", (2.6, -0.8, 0)), ("crate", (0.6, 0.6, 0.45), "#7a5c3a", (0.6, -0.8, 0)), ("wreath stand", (0.1, 0.1, 1.0), WOOD, (-2.75, 2.7, 0)), ("wreath", (0.7, 0.12, 0.7), "#3e5a2e", (-2.75, 2.65, 0.9))], "machine shop": [("bench", (3.2, 0.9, 0.9), "#5b5a52", (0, 2.6, 0)), ("lathe", (1.4, 0.6, 0.5), STEEL, (-0.6, 2.6, 0.9)), ("tool board", (3.0, 0.06, 1.2), "#7a5c3a", (0, 3.3, 1.2)), ("press", (0.8, 0.8, 1.7), "#4a5257", (2.6, 0.6, 0))], "infirmary": bunk(-2.4, 1.5) + bunk(0, 1.5) + bunk(2.4, 1.5) + [("sheet", (0.86, 1.4, 0.04), "#ecebe4", (x, 1.75, 0.53)) for x in (-2.4, 0, 2.4)] + [("medicine cabinet", (1.0, 0.5, 1.6), "#e2e0d6", (-2.8, -1.6, 0))], "drill yard": [("sandbags", (3.6, 0.6, 0.6), "#a08e62", (0, -0.4, 0))] + [("target", (0.8, 0.08, 1.2), "#e2d6b0", (x, 3.1, 0.4)) for x in (-2, 0, 2)] + [("bullseye", (0.3, 0.1, 0.3), "#8a2b22", (x, 3.06, 0.85)) for x in (-2, 0, 2)], "radio room": [("desk", (3.4, 0.9, 0.8), WOOD, (0, 2.8, 0))] + [("radio set", (0.8, 0.5, 0.6), "#3d4a3a", (x, 2.9, 0.8)) for x in (-1.1, 0, 1.1)] + [("map board", (2.4, 0.06, 1.4), "#d8c79c", (-2.2, 3.3, 1.0))], "building": [("scaffold", (0.1, 0.1, 2.6), WOOD, (x, y, 0)) for x in (-1.5, 1.5) for y in (1.0, 2.6)] + [("plank", (3.2, 1.8, 0.06), WOOD, (0, 1.8, 1.6)), ("cement bags", (1.0, 0.6, 0.5), "#b8b2a2", (-2.6, -0.8, 0)), ("crate", (0.8, 0.8, 0.8), "#7a5c3a", (2.6, -1.0, 0))], "plot": [("crate", (0.8, 0.8, 0.8), "#7a5c3a", (2.4, 2.4, 0)), ("crate", (0.6, 0.6, 0.6), "#6b4f31", (2.0, 1.4, 0))], } def furnishing(room): """Which furniture a room has: its own key for a built room, the facility for a facility.""" if room["kind"] == "room": return room["key"] if room["kind"] == "facility": return room["facility"] return room["kind"] class Cutaway: """The war room (warroom.WarRoom) and the base around it. t: seconds since the game opened.""" def __init__(self, base, camp, save=None): from .warroom import WarRoom self.base, self.c = base, camp self.room = WarRoom(base, camp, save=save) self.room.set_shown(False) self.root = base.render.attachNewNode("cutaway") self.place = "base" # "base" (the whole cutaway), "room" (one room), "command" (the table) self.key = None # the room you're at (None: the whole base) self.move = None # {"from": pose, "to": key, "since"}: gliding there self.desks = None self.t = 0.0 self.workers = [] self.build() self.build_ui() self.say("") # ── building it ── def build(self): if getattr(self, "fort", None) is not None: self.fort.removeNode() r = self.fort = self.root.attachNewNode("fort") self.rooms = {d["key"]: d for d in R.doors(self.c)} self.cells, self.workers = {}, [] self.built = (self.c.day, len(self.c.roster), sum(s.dead for s in self.c.roster)) self.build_shell(r) self.build_surface(r) self.build_lift(r) for key, d in self.rooms.items(): self.build_cell(key, d) a = AmbientLight("cutaway ambient") a.setColor(Vec4(0.40, 0.40, 0.39, 1)) r.setLight(r.attachNewNode(a)) dl = DirectionalLight("cutaway fill") dl.setColor(Vec4(0.30, 0.30, 0.30, 1)) d = r.attachNewNode(dl) d.setHpr(20, -35, 0) r.setLight(d) r.setShaderAuto() def build_shell(self, r): """The ground the base is dug into, and the base's own concrete: an outer shell, a slab under each level, a wall between rooms, solid ground where nothing is dug yet, the level numbers.""" w = R.COLUMNS * CELL_W bottom = -R.LEVELS * CELL_H S.box("earth behind", w + 80, 1.0, R.LEVELS * CELL_H + SURFACE + 20, EARTH, (0, DEPTH + 0.5, bottom - 20)).reparentTo(r) S.box("earth under", w + 80, DEPTH, 20.0, EARTH, (0, DEPTH / 2, bottom - 20)).reparentTo(r) for side in (-1, 1): S.box("earth side", 40.0, DEPTH, R.LEVELS * CELL_H + 4, EARTH, (side * (w / 2 + 20.6), DEPTH / 2, bottom - 4)).reparentTo(r) S.box("outer wall", SHELL, DEPTH, R.LEVELS * CELL_H + SHELL, WALLS, (side * (w / 2 + SHELL / 2), DEPTH / 2, bottom - SHELL)).reparentTo(r) S.box("footing", w + 2 * SHELL, DEPTH, SHELL, WALLS, (0, DEPTH / 2, bottom - SHELL)).reparentTo(r) S.box("roof slab", w + 2 * SHELL, DEPTH, SHELL, WALLS, (0, DEPTH / 2, -SHELL)).reparentTo(r) for level in range(R.LEVELS): S.box("slab", w, DEPTH, WALL, SLABS, (0, DEPTH / 2, -(level + 1) * CELL_H + CELL_H - WALL)).reparentTo(r) sign = self.stencil(r, f"B{level + 1}", 0.9, "#d9c25a") sign.setPos(-w / 2 - SHELL / 2, -0.06, -(level + 1) * CELL_H + 1.2) used = {(lv, c) for lv, col, span in R.LAYOUT.values() for c in range(col, col + span)} inside = {(lv, c) for lv, col, span in R.LAYOUT.values() for c in range(col + 1, col + span)} for level in range(R.LEVELS): z = -(level + 1) * CELL_H for col in range(1, R.COLUMNS): # the walls between columns (not across a room) if (level, col) in inside: continue x = (col - R.COLUMNS / 2) * CELL_W S.box("wall", WALL, DEPTH, CELL_H - WALL, WALLS, (x, DEPTH / 2, z)).reparentTo(r) for col in range(R.COLUMNS): if col != R.LIFT and (level, col) not in used: # solid ground: nothing dug here yet x = (col + 0.5 - R.COLUMNS / 2) * CELL_W S.box("ground", CELL_W, DEPTH, CELL_H - WALL, EARTH, (x, DEPTH / 2, z)).reparentTo(r) for k in range(4): S.box("stone", 0.6 + k * 0.15, 0.2, 0.4 + k * 0.1, ROCK, (x - 2.2 + k * 1.4, -0.05, z + 0.4 + (k % 2) * 1.3)).reparentTo(r) def stencil(self, parent, text, size, colour="#e8e2cc", plate=None): """Painted lettering (or, with plate, a sign plate behind it), facing the view (-y).""" tn = TextNode(f"stencil {text}") tn.setText(text) tn.setAlign(TextNode.ACenter) tn.setTextColor(*S.rgba(colour)) n = parent.attachNewNode("stencil") t = n.attachNewNode(tn) t.setScale(size) t.setY(-0.03) t.setLightOff() if plate: w = tn.getWidth() * size + size * 0.8 S.box("plate", w, 0.04, size * 1.5, plate, (0, 0.0, -size * 0.45)).reparentTo(n) return n def build_surface(self, r): """Above ground: the blockhouse over the lift, sandbags, the wire, a guard tower, the radio mast, the flag, and the garage's ramp with its gate.""" w = R.COLUMNS * CELL_W top = SURFACE + 0.15 S.box("earth over", w + 80, DEPTH, SURFACE, EARTH, (0, DEPTH / 2, 0)).reparentTo(r) S.box("ground", w + 80, DEPTH, 0.15, GRASS, (0, DEPTH / 2, SURFACE)).reparentTo(r) lx = (R.LIFT + 0.5 - R.COLUMNS / 2) * CELL_W S.box("blockhouse", 5.0, 4.0, 2.6, WALLS, (lx, DEPTH / 2, top)).reparentTo(r) S.box("blockhouse roof", 5.6, 4.6, 0.35, SLABS, (lx, DEPTH / 2, top + 2.6)).reparentTo(r) S.box("blast door", 2.2, 0.1, 2.0, STEEL, (lx, DEPTH / 2 - 2.05, top)).reparentTo(r) self.hazard(r, lx, DEPTH / 2 - 2.1, top + 2.0, 2.6) for k in range(5): # sandbags either side of the door for side in (-1, 1): S.box("sandbag", 0.9, 0.5, 0.32, SANDBAG, (lx + side * (1.9 + (k % 2) * 0.45), DEPTH / 2 - 2.6, top + (k // 2) * 0.3)).reparentTo(r) for x in [-w / 2 + 1 + i * 3.0 for i in range(int(w / 3) + 1)]: # the wire along the back S.box("fence post", 0.1, 0.1, 2.2, STEEL, (x, DEPTH - 0.4, top)).reparentTo(r) for z in (0.7, 1.4, 2.1): S.box("wire", w - 1, 0.03, 0.03, "#8f948c", (0, DEPTH - 0.4, top + z)).reparentTo(r) tx = w / 2 + 4.5 # the guard tower, out on the right for dx in (-0.9, 0.9): for dy in (-0.9, 0.9): S.box("tower leg", 0.15, 0.15, 4.0, WOOD, (tx + dx, DEPTH / 2 + dy, top)).reparentTo(r) S.box("tower cabin", 2.4, 2.4, 1.1, WOOD, (tx, DEPTH / 2, top + 4.0)).reparentTo(r) S.box("tower roof", 2.8, 2.8, 0.2, "#3f3b33", (tx, DEPTH / 2, top + 5.6)).reparentTo(r) for dx in (-1.1, 1.1): S.box("tower post", 0.1, 0.1, 0.5, WOOD, (tx + dx, DEPTH / 2 - 1.1, top + 5.1)).reparentTo(r) S.box("searchlight", 0.5, 0.6, 0.4, "#c9c7bd", (tx + 0.6, DEPTH / 2 - 1.2, top + 5.1)).reparentTo(r) mx = w / 2 - 0.5 # the radio mast mast = S.cylinder("radio mast", 0.08, 7.5, STEEL) mast.reparentTo(r) mast.setPos(mx, DEPTH / 2, top) for k in range(4): S.box("mast arm", 1.4 - k * 0.25, 0.06, 0.06, STEEL, (mx, DEPTH / 2, top + 3.0 + k * 1.3)).reparentTo(r) S.box("mast light", 0.18, 0.18, 0.18, "#c0392b", (mx, DEPTH / 2, top + 7.5)).reparentTo(r) pole = S.cylinder("flag pole", 0.05, 4.2, "#c8c4b8") pole.reparentTo(r) pole.setPos(lx + 4.0, DEPTH / 2, top) S.box("flag", 1.2, 0.04, 0.7, "#4d5a33", (lx + 4.65, DEPTH / 2, top + 3.4)).reparentTo(r) for i, (x, sw, sh) in enumerate(((-6.5, 2.2, 1.0), (8.0, 1.6, 1.4))): # the old town's ruins, inside the wire S.box("ruin", sw, 1.0, sh, "#7d786c" if i % 2 else "#8a877a", (x, DEPTH * 0.65, top)).reparentTo(r) # the vehicle entrance: the ramp runs back into the hill behind the garage, up to this portal x0, x1, _, _ = cell("garage") gx = (x0 + x1) / 2 + 2.0 for side in (-1, 1): S.box("portal wall", 0.5, 2.0, 2.8, WALLS, (gx + side * 2.3, DEPTH * 0.55, top)).reparentTo(r) S.box("portal lintel", 5.1, 2.0, 0.5, SLABS, (gx, DEPTH * 0.55, top + 2.8)).reparentTo(r) S.box("portal mouth", 4.1, 0.1, 2.8, "#1d1b17", (gx, DEPTH * 0.55 + 0.9, top)).reparentTo(r) self.hazard(r, gx, DEPTH * 0.55 - 1.02, top + 2.8, 5.1) S.box("gate post", 0.25, 0.25, 1.2, "#c8c4b8", (gx - 3.2, DEPTH * 0.55 - 1.6, top)).reparentTo(r) for k in range(6): S.box("barrier", 0.6, 0.12, 0.12, "#c0392b" if k % 2 else "#e8e2cc", (gx - 2.8 + k * 0.6, DEPTH * 0.55 - 1.6, top + 1.05)).reparentTo(r) sky = S.box("sky", 400, 1, 200, "#7d8a92", (0, DEPTH + 60, -40)) sky.reparentTo(r) sky.setLightOff() def hazard(self, parent, x, y, z, width, h=0.18): """Yellow and black stripes across width, centred on x.""" n = int(width / 0.3) for k in range(n): S.box("hazard", width / n, 0.04, h, "#d9b23a" if k % 2 else "#1d1d1b", (x - width / 2 + (k + 0.5) * width / n, y, z)).reparentTo(parent) def build_lift(self, r): x = (R.LIFT + 0.5 - R.COLUMNS / 2) * CELL_W bottom = -R.LEVELS * CELL_H S.box("shaft", CELL_W - WALL, 0.3, R.LEVELS * CELL_H, "#3f3d38", (x, DEPTH - 0.15, bottom)).reparentTo(r) for side in (-1, 1): S.box("rail", 0.15, 0.15, R.LEVELS * CELL_H, STEEL, (x + side * 1.6, DEPTH - 1.3, bottom)).reparentTo(r) for level in range(R.LEVELS): # each level's landing: striped edge, gates z = -(level + 1) * CELL_H for side in (-1, 1): S.box("landing", 1.4, DEPTH, 0.08, CONCRETE, (x + side * 2.55, DEPTH / 2, z)).reparentTo(r) self.hazard(r, x + side * 1.85, 0.3, z + 0.08, 0.3, h=0.04) sign = self.stencil(r, f"LIFT B{level + 1}", 0.32, "#1d1d1b", plate="#d9b23a") sign.setPos(x, DEPTH - 0.35, z + CELL_H - WALL - 0.55) self.lift = r.attachNewNode("lift car") S.box("lift floor", 3.0, 3.0, 0.15, STEEL, (0, 0, 0)).reparentTo(self.lift) for side in (-1, 1): S.box("lift side", 0.08, 3.0, 2.4, "#5d625c", (side * 1.46, 0, 0.15)).reparentTo(self.lift) S.box("lift top", 3.0, 3.0, 0.12, STEEL, (0, 0, 2.55)).reparentTo(self.lift) self.hazard(self.lift, 0, -1.52, 0.0, 3.0) self.lift.setPos(x, DEPTH - 2.0, -CELL_H) self.lift_x = x self.light_cell(r, (x, DEPTH / 2, -CELL_H * 2), "lift", strength=0.4) def build_cell(self, key, d): """One room: its shell (no front: the cut), painted walls, pipes and lights overhead, a door at the back, furniture, a worker, its sign.""" x0, x1, z0, z1 = cell(key) n = self.fort.attachNewNode(f"cell {key}") n.setTag("room", key) n.setPos((x0 + x1) / 2, 0, z0) w, h = x1 - x0, z1 - z0 level = R.LAYOUT[key][0] if d["kind"] == "rubble": S.box("rubble back", w, DEPTH, h, EARTH, (0, DEPTH / 2, 0)).reparentTo(n) for k, (bx, bz, s) in enumerate(((-2.2, 0, 1.2), (-0.6, 0, 1.0), (1.0, 0, 1.3), (2.4, 0, 0.9), (-1.4, 0.9, 0.9), (0.4, 1.0, 1.0), (1.8, 1.1, 0.8), (-0.4, 1.9, 0.7), (1.0, 2.0, 0.6))): rock = S.box("rubble", s, s * 0.8, s * 0.7, "#6d675d" if k % 2 else "#7d6f5c", (bx, -0.1, bz)) rock.reparentTo(n) rock.setHpr(k * 23, k * 7, k * 11) for k in range(3): # the timbers holding it up S.box("shoring", 0.2, 0.2, h, WOOD, (-2.6 + k * 2.6, 0.3, 0)).reparentTo(n) else: S.box("floor", w, DEPTH, 0.08, CONCRETE, (0, DEPTH / 2, 0)).reparentTo(n) S.box("floor line", w - 0.4, 0.08, 0.01, "#d9b23a", (0, 0.35, 0.08)).reparentTo(n) S.box("back wall", w, 0.1, DADO, OLIVE, (0, DEPTH - 0.05, 0)).reparentTo(n) # two-tone paint S.box("back wall", w, 0.1, h - DADO, PAINT, (0, DEPTH - 0.05, DADO)).reparentTo(n) S.box("stripe", w, 0.11, 0.06, "#2d3122", (0, DEPTH - 0.05, DADO)).reparentTo(n) for side in (-1, 1): S.box("side paint", 0.05, DEPTH, DADO, OLIVE, (side * (w / 2 - 0.03), DEPTH / 2, 0)).reparentTo(n) S.box("side paint", 0.05, DEPTH, h - DADO, PAINT, (side * (w / 2 - 0.03), DEPTH / 2, DADO)).reparentTo(n) S.box("ceiling", w, DEPTH, 0.06, "#4a4944", (0, DEPTH / 2, h - 0.06)).reparentTo(n) for k, (py, rad, col) in enumerate(((DEPTH - 0.5, 0.09, "#6b5a46"), (DEPTH - 0.85, 0.06, "#5b6656"), (1.0, 0.05, "#7a7a72"))): S.box("pipe", w, rad * 2, rad * 2, col, (0, py, h - 0.25 - k * 0.06)).reparentTo(n) for fx in ([-w / 4, w / 4] if w > 8 else [0]): # the strip lights S.box("strip light", 1.4, 0.25, 0.08, "#f4f1e6", (fx, DEPTH / 2, h - 0.16)).reparentTo(n) for lamp in n.findAllMatches("strip light"): lamp.setLightOff() door = n.attachNewNode("door") # the door at the back, to the passage door.setPos(w / 2 - 1.2, DEPTH - 0.12, 0.08) S.box("door frame", 1.3, 0.06, 2.2, "#3d3f3a", (0, 0, 0)).reparentTo(door) S.box("door", 1.1, 0.08, 2.05, STEEL, (0, -0.02, 0)).reparentTo(door) S.box("door wheel", 0.3, 0.1, 0.3, "#c0392b", (0, -0.07, 1.05)).reparentTo(door) self.hazard(door, 0, -0.04, 2.2, 1.3, h=0.12) kind = furnishing(d) for name, size, colour, (fx, fy, fz) in FURNITURE.get(kind, []): S.box(name, *size, colour, (fx, *room_xy(fx, fy)[1:], fz)).reparentTo(n) if key == "rec": self.memorial_wall(n, w, h) if key == "garage": # the roll-up door to the ramp S.box("vehicle door", 4.4, 0.08, 1.9, "#6f7368", (1.2, DEPTH - 0.13, 0.08)).reparentTo(n) for k in range(6): S.box("door slat", 4.4, 0.1, 0.03, "#5a5e55", (1.2, DEPTH - 0.15, 0.3 + k * 0.3)).reparentTo(n) self.hazard(n, 1.2, DEPTH - 0.16, 1.98, 4.6) if kind in STAFF: sx, sy, sh, colour = STAFF[kind] worker, arms, _ = figure(f"worker {key}", colour) worker.reparentTo(n) worker.setPosHpr(sx, room_xy(sx, sy)[1], 0.08, sh, 0, 0) self.workers.append(arms) number = f"B{level + 1}-{R.LAYOUT[key][1] + 1:02d}" sign = self.stencil(n, f"{number} {d['name'].upper()}", 0.4, "#e8e2cc", plate="#2d3122") sign.setPos(-0.6, DEPTH - 0.16, h - 1.0) # clear of the pipes and the door n.setCollideMask(PICK) self.light_cell(n, (0, DEPTH / 2, h - 0.5), key) self.cells[key] = n def memorial_wall(self, n, w, h): """The rec area's memorial: a plaque for each of the fallen, on the back wall's left.""" from . import briefs as B gone = B.fallen(self.c) S.box("memorial board", 3.2, 0.06, 1.75, "#4a3523", (-0.7, DEPTH - 0.13, 0.55)).reparentTo(n) head = self.stencil(n, "IN MEMORY", 0.2, "#d8c27a") head.setPos(-0.7, DEPTH - 0.17, 2.05) for i, s in enumerate(gone[:16]): col, row = i % 2, i // 2 px, pz = -1.45 + col * 1.5, 1.8 - row * 0.15 S.box("plaque", 1.35, 0.03, 0.12, "#b8963e", (px, DEPTH - 0.17, pz)).reparentTo(n) t = self.stencil(n, s.name, 0.075, "#2a2116") t.setPos(px, DEPTH - 0.18, pz + 0.035) self.plaques = len(gone[:16]) def light_cell(self, n, pos, name, strength=0.75): p = PointLight(f"lamp {name}") p.setColor(Vec4(strength, strength, strength * 0.95, 1)) p.setAttenuation((1, 0, 0.04)) lamp = n.attachNewNode(p) lamp.setPos(*pos) n.setLight(lamp) def build_ui(self): from direct.gui.DirectGui import DirectButton for old in self.base.aspect2d.findAllMatches("cutaway *"): old.removeNode() tn = TextNode("cutaway say") tn.setWordwrap(34) tn.setTextColor(*S.rgba("#f2ead2")) tn.setCardColor(0.1, 0.09, 0.07, 0.82) tn.setCardAsMargin(0.6, 0.6, 0.4, 0.4) self.say_text = tn n = self.say_np = self.base.aspect2d.attachNewNode(tn) n.setScale(0.045) n.setPos(-self.base.getAspectRatio() + 0.06, 0, -0.7) ar = self.base.getAspectRatio() style = dict(scale=0.05, pad=(0.4, 0.25), text_fg=(0.95, 0.92, 0.82, 1), frameColor=(0.24, 0.27, 0.16, 1)) self.use_btn = DirectButton(text="Use", pos=(ar - 0.3, 0, -0.76), command=self.use, **style) self.use_btn.setName("cutaway use") self.use_btn.hide() self.tabs = {} gap = 2 * ar / len(R.TABS) for i, (key, label) in enumerate(R.TABS): b = DirectButton(text=label, scale=0.045, pad=(0.3, 0.3), frameSize=(-gap / 0.09 + 0.1, gap / 0.09 - 0.1, -0.8, 1.2), pos=(-ar + gap * (i + 0.5), 0, -0.955), command=self.go_to, extraArgs=[key], text_fg=(0.95, 0.92, 0.82, 1), frameColor=(0.18, 0.2, 0.13, 1)) b.setName(f"cutaway tab {key}") self.tabs[key] = b self.picker = CollisionTraverser("cutaway picker") self.hits = CollisionHandlerQueue() ray = CollisionNode("cutaway ray") ray.setFromCollideMask(PICK) ray.setIntoCollideMask(BitMask32.allOff()) self.ray = CollisionRay() ray.addSolid(self.ray) self.picker.addCollider(self.base.camera.attachNewNode(ray), self.hits) self.base.accept("mouse1", self.click) # one click handler for the table and the base self.mark_tab() # ── what you see and say ── def say(self, text): """A line for the player; "" puts back the line for where you are.""" if not text: d = self.rooms.get(self.key) text = f"{d['name']}. {d['about']}" if d and self.place == "room" else BASE_HINT self.say_text.setText(text) def mark_tab(self): """The tab for where you are (or are going) lit; the rest dark.""" here = self.move["to"] if self.move else (self.key or "base") for key, b in self.tabs.items(): b["frameColor"] = (0.42, 0.47, 0.26, 1) if key == here else (0.18, 0.2, 0.13, 1) def pick(self, mx, my): """The room under the screen point (mx, my), each -1..1 -> its key, or None.""" self.ray.setFromLens(self.base.camNode, mx, my) self.picker.traverse(self.fort) if not self.hits.getNumEntries(): return None self.hits.sortEntries() return self.hits.getEntry(0).getIntoNodePath().findNetTag("room").getTag("room") def click(self): if self.place == "command": self.room.click() return mw = self.base.mouseWatcherNode if mw is not None and mw.hasMouse() and not mw.getOverRegion(): self.click_at(mw.getMouseX(), mw.getMouseY()) def click_at(self, mx, my): """A click on the cutaway at screen point (mx, my): go to the room there (not mid-glide).""" key = self.pick(mx, my) if self.move is None else None if key and key != self.key: self.go_to(key) # ── moving about ── def pose(self): """Where the view is meant to be, standing still where you are.""" if self.place == "command" or self.key == "command": return room_pose("command") return room_pose(self.key) if self.key else base_pose() def go_to(self, key): """Glide to room key, or "base" for the whole cutaway (no game days pass).""" here = self.move["to"] if self.move else (self.key or "base") if key == here: return start = self.view_now() if self.place == "command": # off the table: back out into the cutaway self.room.set_shown(False) self.root.show() self.place = "moving" self.move = {"from": start, "to": key, "since": self.t} self.use_btn.hide() self.say_np.show() d = self.rooms.get(key) self.say(f"To the {d['name'].lower()}." if d else "The whole fort.") self.mark_tab() def view_now(self): if self.move: return glide(self.move["from"], self.target(self.move["to"]), (self.t - self.move["since"]) / GLIDE_SECONDS) return self.pose() def target(self, key): return base_pose() if key == "base" else room_pose(key) def arrive(self, key): self.move = None if key == "base": self.place, self.key = "base", None elif key == "command": self.place, self.key = "command", "command" self.root.hide() self.say_np.hide() self.room.rebuild() self.room.set_shown(True, self.t) else: self.place, self.key = "room", key d = self.rooms[key] if d["enter"] and d["control"]: self.use_btn["text"] = R.BUTTON[d["control"]] self.use_btn.resetFrameSize() self.use_btn.show() self.say("") self.mark_tab() def use(self): """The room's control: its window (campaignview.BunkerDesks).""" d = self.rooms.get(self.key) if self.place != "room" or not d or not d["enter"] or not d["control"]: return desks = self.the_desks() {"roster": desks.open_roster, "convoy": desks.open_convoy, "facilities": desks.open_facilities, "memorial": desks.open_memorial}[d["control"]]() def the_desks(self): if self.desks is None: from .campaignview import BunkerDesks self.desks = BunkerDesks(self.room.tk_root(), self.c, self.say, self.changed, on_caravan=self.room.caravan_out) return self.desks def changed(self): """Something was done at a desk: save, the day counter, and the base as it is now (a build in hand shows on its plot, a finished one has its room).""" self.room.saved() self.room.update_hud() self.build() # ── time ── def at(self, t): self.t = t self.room.at(t, camera=self.place == "command") if self.place == "command": return if self.built != (self.c.day, len(self.c.roster), sum(s.dead for s in self.c.roster)): self.build() # a day went by (the trip): builds, the fallen if self.place == "room": self.say("") if self.move and t - self.move["since"] >= GLIDE_SECONDS: self.arrive(self.move["to"]) if self.place == "command": return pos, hpr = self.view_now() self.base.camera.setPosHpr(self.root, *pos, *hpr) k = (t % 16) / 16 # the lift goes down and up, 16 s a round level = 3 * (k * 2 if k < 0.5 else 2 - k * 2) self.lift.setZ(-(ease(level / 3) * 3 + 1) * CELL_H) for i, arms in enumerate(self.workers): arms[1].setP(-60 - 25 * math.sin(t * 2.2 + i)) def tick(self, task): self.room.keys(task.time) # the map's keys and drag (only at the table) self.at(task.time) if self.room.tk is not None: try: self.room.tk.update() # the plan, battle and desk windows except tk.TclError: self.room.tk = None return task.cont